package IBBB.view;

import IBBB.model.UserMessage;
import IBBB.model.WordStockMessage;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TabPane;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;

import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class RootPane {
    @FXML
    private AnchorPane queryWord;
    @FXML
    private TabPane rootPane;
    @FXML
    private AnchorPane newPlan;
    @FXML
    private AnchorPane startLearn;
    @FXML
    private AnchorPane personalMessage;
    private UserMessage userMessage;
    private WordStockMessage wordStockMessage;


    public void init(UserMessage userMessage, WordStockMessage wordStockMessage) throws IOException {
        this.userMessage = userMessage;
        this.wordStockMessage = wordStockMessage;
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(getClass().getResource("BeginLearn.fxml"));
        StackPane startLearnPane = loader.load();
        BeginLearn beginLearn = loader.getController();
        beginLearn.init(userMessage, wordStockMessage);
        startLearn.getChildren().add(startLearnPane);
        AnchorPane.setLeftAnchor(startLearnPane, 0.0);
        AnchorPane.setRightAnchor(startLearnPane, 0.0);
        AnchorPane.setTopAnchor(startLearnPane, 0.0);
        AnchorPane.setBottomAnchor(startLearnPane, 0.0);

        FXMLLoader loader2 = new FXMLLoader();
        loader2.setLocation(getClass().getResource("NewPlan.fxml"));
        ScrollPane newPlanPane = loader2.load();
        NewPlan newPlanController = loader2.getController();
        newPlanController.init(userMessage, wordStockMessage);
        newPlan.getChildren().add(newPlanPane);
        AnchorPane.setLeftAnchor(newPlanPane, 0.0);
        AnchorPane.setRightAnchor(newPlanPane, 0.0);
        AnchorPane.setTopAnchor(newPlanPane, 0.0);
        AnchorPane.setBottomAnchor(newPlanPane, 0.0);

        FXMLLoader loader3 = new FXMLLoader();
        loader3.setLocation(getClass().getResource("PersonalMessagePane.fxml"));
        ScrollPane personalMessagePane = loader3.load();
        PersonalMessagePane personalMessagePaneController = loader3.getController();
        personalMessagePaneController.init(userMessage, wordStockMessage);
        personalMessage.getChildren().add(personalMessagePane);
        AnchorPane.setLeftAnchor(personalMessagePane, 0.0);
        AnchorPane.setRightAnchor(personalMessagePane, 0.0);
        AnchorPane.setTopAnchor(personalMessagePane, 0.0);
        AnchorPane.setBottomAnchor(personalMessagePane, 0.0);

        FXMLLoader loader4 = new FXMLLoader();
        loader4.setLocation(getClass().getResource("QueryWord.fxml"));
        BorderPane queryWordPane = loader4.load();
        queryWord.getChildren().add(queryWordPane);
        AnchorPane.setLeftAnchor(queryWordPane, 0.0);
        AnchorPane.setRightAnchor(queryWordPane, 0.0);
        AnchorPane.setTopAnchor(queryWordPane, 0.0);
        AnchorPane.setBottomAnchor(queryWordPane, 0.0);
    }
}
